import { ApiProperty } from '@nestjs/swagger';
import { IsInt, IsString } from 'class-validator';
import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity()
export class WordCollection {
  @ApiProperty({ description: 'id' })
  @IsInt()
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: '用户id' })
  @IsString()
  @Column()
  userId: string;

  @ApiProperty({ description: '单词' })
  @Column()
  @IsString()
  text: string;

  @ApiProperty({ description: '拼音' })
  @Column()
  @IsString()
  pinyin: string;

  @ApiProperty({
    description:
      '翻译、翻译的文字、音频文件（包含文件大小和文件路径）, 前端怎么存后端就怎么返回',
  })
  @Column()
  @IsString()
  translation: string;

  @ApiProperty({ description: '来源的句子' })
  @Column()
  @IsString()
  source: string;

  @ApiProperty()
  @CreateDateColumn({ type: 'timestamptz' })
  createdAt: string;

  @ApiProperty()
  @UpdateDateColumn({
    type: 'timestamptz',
    // default: () => 'CURRENT_TIMESTAMP',
    // onUpdate: 'CURRENT_TIMESTAMP',
  })
  updatedAt: string;
}
